(function ($) {
    $.fn.objTheme = function (InIt) {

        var controlMapExisting=new Array(0);
        var controlMapCurrent=new Array(0);
        var xmlName = '';

        this.onLoad = function () {

	    var index=0 ;

            this.loadHTML();
            document.getElementById("title").innerHTML = jQuery.i18n.prop(InIt);

	    xml = getData(xmlName);

            var arrayLabels = document.getElementsByTagName("label");
            lableLocaliztion(arrayLabels);
	    var buttonID = document.getElementById("btUpdate").id;
            buttonLocaliztion(buttonID);

	    var theme;
            theme = $(xml).find("name").text();
            document.getElementById("themedrpdown").value = theme;

            controlMapExisting = g_objXML.putMapElement(controlMapExisting,index, "RGW/theme/name", theme);
            controlMapCurrent = g_objXML.copyArray(controlMapExisting,controlMapCurrent);
             $('#themedrpdown').focus();
             $('#themedrpdown').focus();
           
	}

        this.onPost  =  function  () {

	    var _controlMap = this.getPostData();

	    if(_controlMap.length>0){
		//alert(g_objXML.getXMLDocToString(g_objXML.createXML(_controlMap)));
		postXML(xmlName, g_objXML.getXMLDocToString(g_objXML.createXML(_controlMap)));
		//this.onLoad();
		
	    }

        }
        this.onPostSuccess = function(){
          sm('MBConfirmTheme',360,170);

        this.onLoad(false);
        
        }
        this.getPostData = function (){
            var index = 0;
            var mapData = new Array(0);
	    controlMapCurrent[index++][1] = encodeURIComponent(document.getElementById("themedrpdown").value);   
            mapData = g_objXML.copyArray(controlMapCurrent,mapData);
            mapData = g_objXML.getChangedArray(controlMapExisting,mapData,true);
            return mapData;
        }

	this.setXMLName = function (_xmlname){
            xmlName = _xmlname;
        }

	this.loadHTML = function() {
	    document.getElementById('Content').innerHTML = "";
	    document.getElementById('Content').innerHTML = callProductHTML("html/router/change_theme.html");
        }
        return this.each(function () {


	    });
    }
})(jQuery);

function ThemeConfirmed(){
    clearAuthheader();
}